package com.itheima.service.Impl;

import com.itheima.mapper.ClazzMapper;
import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.ClazzCountOption;
import com.itheima.pojo.JobDivision;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private ClazzMapper clazzMapper;
    @Override
    public JobDivision getEmpJobData() {
        List<Map<String, Object>>list = empMapper.countEmpJobData();
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos") ).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total") ).toList();
        return new JobDivision(jobList, dataList);
    }
    @Override
    public List<Map> getGenderData() {
        return empMapper.countEmpGenderData();
    }
    @Override
    public ClazzCountOption getClazzCountOptionData() {
       List< Map<String,Object> > list= clazzMapper.getClazzCountOptionData();
       List<Object> clazzList = list.stream().map(dataMap -> dataMap.get("pos") ).toList();
       List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total") ).toList();
        return new ClazzCountOption(clazzList, dataList);
    }

    @Override
    public List<Map> countDegreeData() {
        return clazzMapper.countDegreeData();
    }

}
